<?php 
$de = array();
$getUrl = "";
if($_POST['act']){
	unset($_GET['s']);
	unset($_GET['m']);
	unset($_GET['operation']);
	if($_POST['act'] == 'save'){//新增
		$sql = "insert into ".SHAREDATA." (url,title,pic,`desc`,`status`,create_user) values('{$_POST['url']}','{$_POST['title']}','{$_POST['pic']}','{$_POST['desc']}','{$_POST['status']}','{$_SESSION['ADMIN_USER']}')";
		$db->query($sql);
	}
	if($_POST['act'] == 'edit' && $_POST['id']>0){//编辑
		$sql = "update ".SHAREDATA." set url='{$_POST['url']}',title='{$_POST['title']}',pic='{$_POST['pic']}',`desc`='{$_POST['desc']}',`status`='{$_POST['status']}' where id='{$_POST['id']}'";
		$db->query($sql);
	}
	unset($_GET['editid']);
	$getstr=implode('&',convert($_GET));
	msg("?m=share_data&s=share_data_list.php&$getstr");
}
if($_GET['operation']=='edit' && $_GET['editid']>0){
	$sql = "select * from ".SHAREDATA." where id='{$_GET['editid']}'";
	$db->query($sql);
	$de = $db->fetchRow();
}else{
	$getUrl = $_GET['share_url'];
	$sql = "select id from ".SHAREDATA." where url='{$getUrl}' limit 1";
	$db->query($sql);
	$res = $db->fetchField('id');
	if($res>0){
		msg('?m=share_data&s=share_data_add_edit.php&operation=edit&editid='.$res);
	}
}

$tpl->assign('de',$de);
$tpl->assign('getUrl',$getUrl);
$tpl->assign("config",$config);
$tpl->display("share_data_add_edit.htm");
?>